
module Remote

  class Query
    def initialize url
      @server = Server.new(url)
    end

    def all filter = {}
      select :all, filter
    end

    def first filter = {}
      select :first, filter
    end

    def first filter = {}
      select :last, filter
    end

    def select kind, filter
      @server.ask(
        '/export',
        :select,
        :kind => kind,
        :filter => filter
      )[0]['things']
    end
  end

end
